package com.yvan.demo.web1.controller;

import com.google.common.collect.Lists;
import lombok.val;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

@Controller
public class RootController {

    @GetMapping("/")
    public ModelAndView root() {
        return new ModelAndView(new RedirectView("/index.html"));
    }

    @GetMapping("/index.html")
    public ModelAndView homePage(Model model) {
        model.addAttribute("name", "罗一帆");
        val lists = Lists.newArrayList();
        for (int i = 0; i < 10; i++) {
            lists.add(i);
        }
        model.addAttribute("lists", lists);
        return new ModelAndView("/index.ftl");
    }

}
